package com.hqq.behaviour.strategy;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * App
 * Created by heqianqian on 2017/6/19.
 */
public class App {

    private static final Logger LOGGER = LoggerFactory.getLogger(App.class);

    public static void main(String[] args) {

        ProjectileStrategy projectileStrategy = new ProjectileStrategy();
        SpellStrategy spellStrategy = new SpellStrategy();
        MeleeStrategy meleeStrategy = new MeleeStrategy();

        LOGGER.info("Green dragon spotted ahead!");
        DragonSlayer dragonSlayer = new DragonSlayer(projectileStrategy);
        dragonSlayer.goToBattle();
        LOGGER.info("Red dragon emerges.");
        dragonSlayer.changeStrategy(spellStrategy);
        dragonSlayer.goToBattle();
        LOGGER.info("Black dragon lands before you.");
        dragonSlayer.changeStrategy(meleeStrategy);
        dragonSlayer.goToBattle();

        LOGGER.info("Green dragon spotted ahead!");
        dragonSlayer = new DragonSlayer(() -> LOGGER.info("With your Excalibur you severe the dragon's head!"));
        dragonSlayer.goToBattle();
        LOGGER.info("Red dragon emerges.");
        dragonSlayer.changeStrategy(() -> LOGGER.info("You shoot the dragon with the magical crossbow and it falls dead on the ground!"));
        dragonSlayer.goToBattle();
        LOGGER.info("Black dragon lands before you.");
        dragonSlayer.changeStrategy(() -> LOGGER.info(
                "You cast the spell of disintegration and the dragon vaporizes in a pile of dust!"));
        dragonSlayer.goToBattle();
    }
}
